<?php
if(isset($_REQUEST['idtestproject'])){
	session_cache_expire(999999999);
	if(!isset($_SESSION)) 
	{ 
	session_start(); 
	}
	include '../../operations/connection.php';
	$id_testproject = $_REQUEST['idtestproject'];
	$sqltestpro = mysql_query("SELECT pt.*,e.FullName,e.Email,pp.IDView,pp.NameProject FROM pr_testproject pt, employee e,pr_project pp 
	WHERE pt.IDTest ='".$id_testproject."' AND pt.IDEmployee = e.IDEmployee AND pt.IDProject = pp.IDProject");
  $valonetestpro = mysql_fetch_assoc($sqltestpro);
  $nametester = $valonetestpro['FullName'];
  $emailtester = $valonetestpro['Email'];
  $codepro = $valonetestpro['IDView'];
  
  $tesppr_temp = $row['IDTestTemp'];
  $nampro_temp = $row['NameProject'];

  $substr_temp = explode("-", $tesppr_temp);
  $substr_temp_last = $substr_temp[0];

  $codetemp_pro='';
  if ($substr_temp_last==''){
  	$codetemp_pro ='';
  }
  else if ($substr_temp_last==$nampro_temp){
		$codetemp_pro = $codepro."-".$substr_temp[1];
  }else{
		$codetemp_pro = $codepro."-".$tesppr_temp;
	}
  
  $title_test = '';
  $love =  substr($valonetestpro['Title'],0,-14);
  if (strlen($love)==0){
  	$title_test = $valonetestpro['Title'];
  }else{
  	$title_test = $love;
  }
  
  $statustestpro = $valonetestpro['Status'];
  $currentdate = $_SERVER['REQUEST_TIME'];
  
    $addressbrowser = $_SERVER['SERVER_NAME'];
	$temp = explode(".", $addressbrowser);
	$lang=$_SESSION['lang'];
	if($lang==''){
		$lang='EN';
		$_SESSION['lang']="EN";
	}
	
	
	$url = 'http://1.234.53.52/mail/mail_fixed_admin.php';
	$fields = array(
							'lang' => urlencode($lang),
							'codername' => urlencode($username),
							'testername' => urlencode($nametester),
							'emailtester' => urldecode($emailtester),
							'codeproject' => urlencode($codepro),
							'codetestpro' =>  urlencode($codetemp_pro),
							'titletestpro' => urldecode($title_test),
							'statustestpro' => urldecode($statustestpro),
							'company' => urldecode($temp[0]),
							'currentdate' => urldecode($currentdate),
							'nguoiguidi' => urlencode($id_employee)
					);
	/*$url = 'http://localhost/mail/mail_fixed_admin.php';
	$fields = array(
							'lang' => urlencode($lang),
							'codername' => urlencode($username),
							'testername' => urlencode($nametester),
							'emailtester' => urldecode($emailtester),
							'codeproject' => urlencode($codepro),
							'codetestpro' =>  urlencode($codetemp_pro),
							'titletestpro' => urldecode($title_test),
							'statustestpro' => urldecode($statustestpro),
							'company' => urldecode('elitech'),
							'currentdate' => urldecode($currentdate),
							'nguoiguidi' => urlencode($id_employee)
					);*/

	//url-ify the data for the POST
	foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
	rtrim($fields_string, '&');
	
	//open connection
	$ch = curl_init();
	
	//set the url, number of POST vars, POST data
	curl_setopt($ch,CURLOPT_URL, $url);
	curl_setopt($ch,CURLOPT_POST, count($fields));
	curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
	
	//execute post
	$result = curl_exec($ch);
	//echo $ch;
	//close connection
	curl_close($ch);
	mysql_close($connection);
	}
	
?>